

CC=cc
LIBTOOL=/usr/bin/libtool

CFLAGS=-g -O0 -std=c99 -Wall -D_GNU_SOURCE -I/usr/include/mysql
LDFLAGS=-g -O0 -std=c99 -ljson -lcurl -lmysqlclient -rpath /usr/lib/x86_64-linux-gnu

ALL_OBJ=config util list  mysql url

all: ${ALL_OBJ}

config: test_config.c ../common/util.h ../common/config.h
	${LIBTOOL} --mode=compile ${CC} -c ${CFLAGS} test_config.c
	${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ test_config.lo

util: test_util.c ../common/util.h
	${LIBTOOL} --mode=compile ${CC} -c ${CFLAGS} -o util.o test_util.c
	${LIBTOOL} --mode=link ${CC} ${CFLAGS} -o $@ util.o

list: test_list.c ../common/list.h
	${CC} ${CFLAGS} -o $@ $<

mysql:test_mysql.c ../common/list.h ../common/reader.h ../common/util.h
	${LIBTOOL} --mode=compile ${CC} -c ${CFLAGS} -o mysql.o test_mysql.c
	${LIBTOOL} --mode=link ${CC} ${CFLAGS} -lmysqlclient -lcurl -I/usr/include/mysql -o $@ mysql.o

url:test_url.c ../common/list.h ../common/reader.h ../common/util.h
	${LIBTOOL} --mode=compile ${CC} -c ${CFLAGS} -o url.o test_url.c
	${LIBTOOL} --mode=link ${CC} ${CFLAGS} -lmysqlclient -lcurl -I/usr/include/mysql -o $@ url.o
	

clean:
	${LIBTOOL} --mode=clean rm -rf ${ALL_OBJ} .libs/*
	rm -rf *.o *.lo a.out
